import * as modInstances from "./module/index";
import deviceModule from "./module/device";

/**
 * 启动模块
 */
async function initDevice() {
    let needMods = ["idcard", "bcr"];
    let result = []
    for (let mod of deviceModule) {
        let modName = mod.mod.toLowerCase();
        let logicName = mod.logicName;
        let ret = "";
        console.log(modName);
        if (needMods.includes(modName)) {
            try {
                ret = await modInstances[modName].Open(logicName, 90000);
                result.push(ret)
            } catch (error) {
                console.log(error);
            }

            Trace(
                EC_INFO,
                `-- @mod:${modName}.open serverName:${logicName} ret:${ret.ret}`
            );
        }
    }
    return result
}

export default initDevice